// 线程池（是生产者消费者模型的一种应用）
#include "Thread.hpp"
#include <unistd.h>
#include "ThreadPool.hpp"
#include "Task.hpp"

using namespace ThreadNS;

void *Routine(void *args)
{
    string Str = (char *)args;
    while (true)
    {
        cout << Str << " " << pthread_self() << endl;
        sleep(1);
    }
}

int main()
{
    ThreadPool<Task::Task> tp;
    int a, b;
    char op;
    tp.Run();
    while (true)
    {
        cout << "请输入一个运算式子, 不同数字与运算符之间用间隔隔开：";
        cin >> a >> op >> b;
        while (op != '+' && op != '-' && op != '*' && op != '/' && op != '%')
        {
            cout << "请确保输入式子格式正确" << endl;
            cin >> a >> op >> b;
        }
        Task::Task tk(a, b, op);
        tp.push(tk);
        sleep(1);
    }

    return 0;
}